﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using FlotasDesktop;
using System.Data.SqlClient;
           

namespace GestorDeFlotasDesktop.MejoresChoferes
{
    public partial class MejoresChoferes : Form
    {
        String conexion;
        public MejoresChoferes()
        {
            InitializeComponent();
            Utils utils = new Utils();
            conexion = utils.cargarProperties();
        }

        public void cargarListado(int idTrimestre)
        {
            using (SqlConnection connection = new SqlConnection(conexion))
            {
                try
                {
                    using (SqlCommand command = new SqlCommand())
                    {

                        connection.Open();
                        command.Connection = connection;
                        command.CommandType = System.Data.CommandType.StoredProcedure;
                        command.CommandText = "TEQUILASO.sp_mejoresChoferes";


                        command.Parameters.Add(new SqlParameter("@Id_trimestre", idTrimestre));
                        using (SqlDataAdapter adapter = new SqlDataAdapter(command))
                        {
                            DataSet ds = new DataSet();
                            adapter.Fill(ds);
                            dataGridView1.DataSource = ds.Tables[0];

                        }

                        this.Show();

                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }

        private void MejoresChoferes_Load(object sender, EventArgs e)
        {
            
        }

        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }
    }
}
